using B.S.BasicData.EroorCode;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace B.S.BasicData.Api.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class ProindexinfoController : ControllerBase
    {
        private readonly IMediator _mediator;
        public ProindexinfoController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpPost("add")]
        public async Task<ActionResult<ApiResult<B.S.BasicData.Domain.Proindexinfo>>> Add([FromBody] ProindexinfoAddRequest request)
        {
            var result = await _mediator.Send(request);
            return Ok(result);
        }

        [HttpPost("paging")]
        public async Task<ActionResult<ApiPaging<System.Collections.Generic.List<B.S.BasicData.Domain.Proindexinfo>>>> Paging([FromBody] ProindexinfoPagingRequest request)
        {
            var result = await _mediator.Send(request);
            return Ok(result);
        }

        [HttpPost("batch-delete")]
        public async Task<ActionResult<ApiResult<int>>> BatchDelete([FromBody] ProindexinfoBatchDeleteRequest request)
        {
            var result = await _mediator.Send(request);
            return Ok(result);
        }

        [HttpPost("update")]
        public async Task<ActionResult<ApiResult<B.S.BasicData.Domain.Proindexinfo>>> Update([FromBody] ProindexinfoUpdateRequest request)
        {
            var result = await _mediator.Send(request);
            return Ok(result);
        }

        [HttpPost("delete")]
        public async Task<ActionResult<ApiResult<int>>> Delete([FromBody] ProindexinfoDeleteRequest request)
        {
            var result = await _mediator.Send(request);
            return Ok(result);
        }

        [HttpGet("get-by-id")]
        public async Task<ActionResult<ApiResult<B.S.BasicData.Domain.Proindexinfo>>> GetById([FromQuery] int id)
        {
            var result = await _mediator.Send(new ProindexinfoGetByIdRequest { Id = id });
            return Ok(result);
        }

        [HttpGet("get-dto-by-id")]
        public async Task<ActionResult<ApiResult<B.S.BasicData.ApiRead.ProindexinfoPagingDto>>> GetDtoById([FromQuery] int id)
        {
            var result = await _mediator.Send(new ProindexinfoPagingDtoGetByIdRequest { Id = id });
            return Ok(result);
        }
    }
} 